"use server";

import { message } from "antd";
import { getQuestionVoByIdUsingGet } from "@/api/questionController";
import QuestionCard from "@/components/QuestionCard";

// @ts-ignore
/**
 * 题目详情页面
 */

export default async function QuestionPage({ params }) {
  // 获取 url 的查询参数
  let questionId = params.questionId;
  // 获取题库详情
  let question = undefined;
  try {

    const res = await getQuestionVoByIdUsingGet({
      id: questionId,
    });
    question = res.data;

  } catch (e) {
    // @ts-ignore
    message.error("获取题库列表失败，" + e.message);
  }

  // 错误处理
  if (!question) {
    return <div>获取题目详情失败，请刷新重试</div>;
  }

  // @ts-ignore
  return <div id="questionPage-detail">
    <QuestionCard question={question} />
  </div>;
}
